import 'problem_case_list.dart';
import 'problem_rule_model.dart';

class ProblemList {
  String? id;
  String? documentId;
  int? linkType;
  String? linkId;
  String? problemWords;
  String? problemType;
  String? problemContent;
  String? remark;
  String? isValid;
  String? tenantId;
  String? createBy;
  String? createTime;
  String? updateBy;
  String? updateTime;
  List<ProblemRuleModel>? problemRuleList;
  List<ProblemCaseList>? problemCaseList;

  ProblemList({
    this.id,
    this.documentId,
    this.linkType,
    this.linkId,
    this.problemWords,
    this.problemType,
    this.problemContent,
    this.remark,
    this.isValid,
    this.tenantId,
    this.createBy,
    this.createTime,
    this.updateBy,
    this.updateTime,
    this.problemRuleList,
    this.problemCaseList,
  });

  factory ProblemList.fromJson(Map<String, dynamic> json) => ProblemList(
        id: json['id'] as String?,
        documentId: json['documentId'] as String?,
        linkType: json['linkType'] as int?,
        linkId: json['linkId'] as String?,
        problemWords: json['problemWords'] as String?,
        problemType: json['problemType'] as String?,
        problemContent: json['problemContent'] as String?,
        remark: json['remark'] as String?,
        isValid: json['isValid'] as String?,
        tenantId: json['tenantId'] as String?,
        createBy: json['createBy'] as String?,
        createTime: json['createTime'] as String?,
        updateBy: json['updateBy'] as String?,
        updateTime: json['updateTime'] as String?,
        problemRuleList: (json['problemRuleList'] as List<dynamic>?)
            ?.map((e) => ProblemRuleModel.fromJson(e as Map<String, dynamic>))
            .toList(),
        problemCaseList: (json['problemCaseList'] as List<dynamic>?)
            ?.map((e) => ProblemCaseList.fromJson(e as Map<String, dynamic>))
            .toList(),
      );

  Map<String, dynamic> toJson() => {
        'id': id,
        'documentId': documentId,
        'linkType': linkType,
        'linkId': linkId,
        'problemWords': problemWords,
        'problemType': problemType,
        'problemContent': problemContent,
        'remark': remark,
        'isValid': isValid,
        'tenantId': tenantId,
        'createBy': createBy,
        'createTime': createTime,
        'updateBy': updateBy,
        'updateTime': updateTime,
        'problemRuleList': problemRuleList,
        'problemCaseList': problemCaseList?.map((e) => e.toJson()).toList(),
      };
}
